# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=k0sctl
pkgver=0.13.0
pkgrel=0
pkgdesc="Bootstrapping and management tool for k0s clusters"
url="https://github.com/k0sproject/k0sctl"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/k0sproject/k0sctl/archive/refs/tags/v$pkgver/k0sctl-$pkgver.tar.gz"
builddir="$srcdir/k0sctl-$pkgver"

build() {
	make

	for shell in bash fish zsh; do
		./$pkgname completion --shell $shell >$pkgname.$shell
	done
}

check() {
	make test
}

package() {
	make PREFIX=/usr DESTDIR="$pkgdir" install

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/completions/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
e6fa8ceb513c0cfac6fcf60127d599b93f341494a50ab5fd3b37850ce7e010d1bc3f1a8304eb92c6dc7be9a9b9ff72bf500a98fdc7d38cc448eb7be9e014496d  k0sctl-0.13.0.tar.gz
"
